<template>
	<view class="goods_list">
		<goods-list :goods="goods" @goodsItemClick="goGoodsDetail"></goods-list>
		<view class="isOver" v-if="flag">----------我是有底线的----------</view>
	</view>
</template>

<script>
	import goodsList from "../../components/good-list/good-list.vue"
	export default {
		data() {
			return {
				pageIndex: 1,
				flag: false,
				goods: [],
				sampleGoods: [{
						"title": "华为（HUAWEI）荣耀6Plus 16G双4G版",
						"add_time": "2015-04-19T16:51:03.000Z",
						"zhaiyao": "荣耀6 Plus，该机型分为两款型号，分别为PE-",
						"click": 0,
						"img_url": '/static/logo.png',
						"sell_price": 2195,
						"market_price": 2499,
						"stock_quantity": 60
					},
					{
						"title": "华为（HUAWEI）荣耀6Plus 16G双4G版",
						"add_time": "2015-04-19T16:51:03.000Z",
						"zhaiyao": "荣耀6 Plus，该机型分为两款型号，分别为PE-",
						"click": 0,
						"img_url": '/static/logo.png',
						"sell_price": 2195,
						"market_price": 2499,
						"stock_quantity": 60
					}
				]
			}
		},
		components: {
			"goods-list": goodsList
		},
		methods: {
			async getGoodsList() {
				for (var i = 0; i < 4; i++) {
					this.goods = [...this.goods, ...this.sampleGoods]
				}
			},
			goGoodsDetail(id) {
				uni.navigateTo({
					url: '/pages/goods-detail/goods-detail?id=' + id
				})
			}

		},
		onLoad() {
			this.goods = this.sampleGoods
			this.getGoodsList()
		},
		onReachBottom() {
			if (this.goods.length >= 15) return this.flag = true
			// this.pageindex++
			this.getGoodsList()
		},
		onPullDownRefresh() {
			this.goods = []
			this.flag = false
			setTimeout(()=>{
				this.getGoodsList()
				uni.stopPullDownRefresh()
			}, 1000)
		}



	}
</script>

<style>
	.goods_list {
		background: #eee;
	}

	.isOver {
		width: 100%;
		height: 50px;
		line-height: 50px;
		text-align: center;
		background: #fff;
		font-size: 28rpx;
	}
</style>